<html>
<head><meta charset="utf-8"><title>const-ub methods · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html">const-ub methods</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240147906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240147906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240147906">(May 25 2021 at 06:42)</a>:</h4>
<p>Now that <a href="https://github.com/rust-lang/rfcs/pull/3016">RFC 3016</a> has been merged, is there any reason that methods like <code>core::str::from_utf8_unchecked</code> can't be stabilized as <code>const</code>? This specific one is <a href="https://github.com/rust-lang/rust/issues/75196">#75196</a>, but there are plenty of other methods that I imagine are only blocked on this.</p>



<a name="240147987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240147987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240147987">(May 25 2021 at 06:43)</a>:</h4>
<p>Notably, whether the compiler can actively detect the UB and throw a compile error is irrelevant — it's "okay" (in that it's the user's problem) to produce invalid values.</p>



<a name="240152105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240152105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240152105">(May 25 2021 at 07:35)</a>:</h4>
<p>started the FCP process and pinged the const eval wg. let's see what they say :)</p>



<a name="240152483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240152483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240152483">(May 25 2021 at 07:39)</a>:</h4>
<p>Works for me. If this one is okay, then others like const transmute, const union, and many others should be as well.</p>



<a name="240166146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240166146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240166146">(May 25 2021 at 10:10)</a>:</h4>
<p>They are all OK, we just didn't have the capacity to act yet. We should do unions, deref and transmute at the same time though</p>



<a name="240166228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240166228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240166228">(May 25 2021 at 10:11)</a>:</h4>
<p>The UTF8 functions are different though, they can be stabilized without the others, as its unsoundness is library unsoundness</p>



<a name="240171018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240171018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240171018">(May 25 2021 at 11:06)</a>:</h4>
<p>I'll look into creating a PR that stabilizes those three. Stabilization of methods can come separately so as to avoid a megalith of a PR.</p>



<a name="240171481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/const-ub%20methods/near/240171481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/const-ub.20methods.html#240171481">(May 25 2021 at 11:11)</a>:</h4>
<p>See also the discussion in <a class="stream" data-stream-id="146212" href="/#narrow/stream/146212-t-compiler.2Fconst-eval">#t-compiler/const-eval</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>